import Vue from "vue";
import Router from "vue-router";

import Layout from "../components/layout/index.vue";

Vue.use(Router);

export const constantRoutes = [

  {
    path: "/404",
    name: "404",
    component: () => import("../views/404.vue"),
    hidden: true,
  },

  {
    path: "/",
    component: Layout,
    redirect: "/index",
    children: [
      {
        path: "index",
        name: "index",
        component: () => import("../views/home/index.vue"),
      },

      {
        path: "article-detail/:id",
        name: "article-detail",
        component: () => import("../views/article-detail/index.vue"),
      },
      {
        path: "article-list",
        name: "article-list",
        component: () => import("../views/article-list/index.vue"),
      },

      {
        path: "download",
        name: "download",
        component: () => import("../views/download/index.vue"),
      },
      {
        path: "topic",
        name: "topic",
        component: () => import("../views/topic/index.vue"),
        children: [
          {
            path: "topic-teacher",
            name: "topic-teacher",
            component: () => import("../views/topic/teacher/index.vue"),
          },
          {
            path: "topic-material",
            name: "topic-material",
            component: () => import("../views/topic/material/index.vue"),
          },
          ,
          {
            path: "topic-lesson",
            name: "topic-lesson",
            component: () => import("../views/topic/lesson/index.vue"),
          },
          {
            path: "topic-certificate",
            name: "topic-certificate",
            component: () => import("../views/topic/certificate/index.vue"),
          },
        ],
      },


      {
        path: "lesson-video",
        name: "lesson-video",
        component: () => import("../views/topic/lesson/video/index.vue"),
      },
      {
        path: "lesson-exam-process",
        name: "lesson-exam-process",
        meta: {
          hideFooter: true,
        },
        component: () => import("../views/topic/lesson/exam/exam-process.vue"),
      },
      {
        path: "lesson-exam-result",
        name: "lesson-exam-result",
        meta: {
          hideFooter: true,
        },
        component: () => import("../views/topic/lesson/exam/exam-result.vue"),
      },

      {
        path: "lesson-exam-detail",
        name: "lesson-exam-detail",
        meta: {
          hideFooter: true,
        },
        component: () => import("../views/topic/lesson/exam/exam-detail.vue"),
      },

    ],
  },

  { path: "*", redirect: "/404", hidden: true },
];

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    mode: "history",
    routes: constantRoutes,
  });

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher;
}

export default router;
